//
//  MainViewController.swift
//  weibo
//
//  Created by HJ on 16/3/8.
//  Copyright © 2016年 HJ. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        addChildVCs()
        setValue(MainTabBar(), forKey: "tabBar")
    }
    
    private func addChildVC(title : String, imgName : String,vc : UIViewController ){
//        vc.tabBarItem.title = title;
        vc.tabBarItem.image = UIImage(named: imgName)
        vc.tabBarItem.selectedImage = UIImage(named: imgName + "_selected")
       let nav = UINavigationController(rootViewController: vc)
        vc.title = title
//        tabBar.tintColor = UIColor.orangeColor()
//        vc.navigationItem.title = title
        addChildViewController(nav)
        
        
    }
    
    private func addChildVCs(){
        addChildVC("首页", imgName: "tabbar_home", vc: HomeTableViewController())
         addChildVC("消息", imgName: "tabbar_message_center", vc: MessageTableViewController())
         addChildVC("发现", imgName: "tabbar_discover", vc: DiscoverTableViewController())
         addChildVC("我", imgName: "tabbar_profile", vc: ProfileTableViewController())
    }
    

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
